//
//  ReduceCode.m
//  YSFruit
//
//  Created by iMacOne on 16/4/7.
//  Copyright © 2016年 iMacOne. All rights reserved.
//

#import "ReduceCode.h"
#import "Header.h"
@implementation ReduceCode
+ (UIButton *)creatBtnWithFrame:(CGRect)rect btnTitle:(NSString *)titleString btnTitleColor:(UIColor *)color btnTitleFont:(int)font btnBackgroundColor:(UIColor *)BGcolor backgroundImage:(UIImage *)image  isCorner:(BOOL)corner
{
    UIButton * btn =[UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = rect;
    [btn setTitle:titleString forState:UIControlStateNormal];
    [btn setTitleColor:color forState:UIControlStateNormal];
    btn.titleLabel.font = FONT(font);
    btn.backgroundColor = BGcolor;
    [btn setBackgroundImage:image forState:UIControlStateNormal];
    if (corner) {
        btn.layer.cornerRadius = btn.frame.size.width/2;
        btn.clipsToBounds = YES;
    }
    return btn;
}
+ (UILabel *)creatLabelWithFrame:(CGRect)rect title:(NSString*)title titleColor:(UIColor *)color font:(int)font textAlignment:(NSTextAlignment)alignment
{
    UILabel * lbl = [[UILabel alloc]initWithFrame:rect];
    lbl.text = title;
    lbl.font = FONT(font);
    lbl.textColor = color;
    lbl.textAlignment = alignment;
    return lbl;
}
+ (UIImageView *)creatImageVeiwWithFrame:(CGRect)rect imageName:(NSString *)imageName isCorner:(BOOL)isCorner
{
    UIImageView * imageV = [[UIImageView alloc] initWithFrame:rect];
    imageV.image = [UIImage imageNamed:imageName];
    
    if (isCorner) {
        imageV.layer.masksToBounds = YES;
        imageV.layer.cornerRadius = imageV.frame.size.width/2;
    }
    return imageV;
}
+(UITextField *)creatTextFieldWithFrame:(CGRect)rect withplaceholder:(NSString *)placehold withMes:(NSString *)mess {
    
    UITextField *textField= [[UITextField alloc]initWithFrame:rect];
    textField.font = FONT(13);
    //    textField.backgroundColor = kWhiteColor;
    textField.placeholder = placehold;
    //    textField.layer.cornerRadius = 5;
    //    textField.clipsToBounds = YES;
    //    textField.textAlignment =
    textField.clearButtonMode = UITextFieldViewModeWhileEditing;
    textField.text =mess;
    
  
    
    return  textField;
}

+(UITextField *)creatTextFieldWithFrame:(CGRect)rect PlaceHold:(NSString *)placehold PlaceHoldColor:(UIColor *)color btnTitleFont:(int)font btnBackgroundColor:(UIColor *)BGcolor KeyboardType:(UIKeyboardType)keyboardType  isCorner:(BOOL)corner {
    
    UITextField *textField= [[UITextField alloc]initWithFrame:rect];
    textField.placeholder = placehold;
    [textField setValue:color forKeyPath:@"_placeholderLabel.textColor"];
    textField.font = FONT(13);
    textField.backgroundColor = BGcolor;
    textField.keyboardType = keyboardType;
    textField.clearButtonMode = UITextFieldViewModeWhileEditing;
    
    if (corner) {
        textField.layer.cornerRadius = 4;
        textField.clipsToBounds = YES;
    }
    return  textField;
}

@end
